package com.hundsun.cprs.yyt.util;

import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class JDBCUtil {
    
    @Autowired(required=false)
    private JdbcTemplate template;
    
    private static JdbcTemplate jdbcTemplate;
    
    @PostConstruct //在构造对象完之后调用初始化
    public void init() {
        JDBCUtil.jdbcTemplate = template;
    }
    
    public static List<Map<String,Object>> query(String sql){
        return jdbcTemplate.queryForList(sql);
    }

}
